package ${packageName}.${moduleName}.dao.jdbc;

import java.util.List;

import javax.persistence.Query;

import org.springframework.stereotype.Repository;

import com.rd.p2p.common.dao.jpa.BaseDaoImpl;
import ${packageName}.${moduleName}.dao.${ClassName}Dao;
import ${packageName}.${moduleName}.domain.${ClassName};

/**
 * ${functionName}DAO接口
 * TODO
 * @author ${classAuthor}
 * @version 2.0
 * @since ${classDate}
 */
@Repository(value = "${className}Dao")
public class ${ClassName}DaoImpl extends BaseDaoImpl<${ClassName}> implements ${ClassName}Dao {

    @SuppressWarnings("unchecked")
    @Override
    public ${ClassName} get${ClassName}ById(long id) {
        String jpql = "from ${ClassName} where id = ?1";
        Query query = em.createQuery(jpql);
        query.setParameter(1, id);
        List<${ClassName}> list = query.getResultList();
        if (list != null && list.size() >= 0) {
            return (${ClassName}) list.get(0);
        } else {
            return null;
        }
    }
}
